<template>
  <div>
    <div class="banner" @click="handleBannerClick">
      <img class="banner-img" :src="bannerImg" alt="">
      <div class="banner-info">
        <div class="banner-title">{{this.sightName}}</div>
        <div class="banner-number"><span class="icon iconfont icon-xingzhuang-tupian"></span>{{this.bannerImgs.length}}</div>
      </div>
    </div>
    <fade>
      <common-gallary :imgs='bannerImgs' v-show="show" @close="handleGallaryClose"></common-gallary>
    </fade>
  </div>
</template>

<script>
import CommonGallary from 'common/gallary/Gallary'
import axios from 'axios'
import fade from 'common/fade/Fade'
export default {
  name: 'DetailBanner',
  props: {
    bannerImg: String,
    bannerImgs: Array,
    sightName: String
  },
  components: {
    CommonGallary,
    fade
  },
  data () {
    return {
      imgs: [],
      show: false
    }
  },
  methods: {
    getGallary () {
      axios.get('/api/gallary.json')
        .then(this.getGallaryList)
    },
    getGallaryList (res) {
      console.log(res)
      this.imgs = res.data.gallary
    },
    handleBannerClick () {
      this.show = true
    },
    handleGallaryClose () {
      this.show = false
    }
  },
  mounted () {
    this.getGallary()
  }
}
</script>

<style scoped>
.banner{
  overflow: hidden;
  height: 0;
  padding-bottom: 55%;
  position: relative;
}
.banner-img{
  width: 100%;
  display: block;
}
.banner-info{
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  line-height: 30px;
  display: flex;
  color: #fff;
}
.banner-title{
  flex: 1;
  font-size: 16px;
  padding: 0 10px;
}
.banner-number{
  padding: 0 20px;
  line-height: 16px;
  height: 16px;
  border-radius: 10px;
  background: rgba(0,0,0,0.8);
  margin-top:8px;
}
.icon-xingzhuang-tupian{
  margin-right: 8px;
}
</style>
